#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int t;
    cin >> t;
    for (int i=1; i<=t; ++i)
    {
        int ans = 0, one = 0, two = 0;
        int n, inp;
        scanf("%d", &n);
        //if (i==19)for(int k=1; k<=19; ++k){int tmp; scanf("%d", &tmp); printf("%d ", tmp);continue;}
        for (int j=1; j<=n; ++j)
        {
            scanf("%d", &inp);
            if (inp==0) continue;
            if (inp%3==0) {++ans; continue;}
            if (inp%3==1) {++one; continue;}
            if (inp%3==2) {++two; continue;}
        }
        if (two == one) ans += one;
        else if (two > one) {ans += one; two -= one; ans += two/3;}
        else if (two < one)  {ans += two; one -= two; ans += one/3;}
        cout << ans << endl;
    }
    return 0;
}

